package cn.itcast.bos.mq;

import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Service;

import cn.itcast.bos.utils.SmsUtils;

@Service("smsConsumer")
public class SmsConsumer implements MessageListener {

	@Override
	public void onMessage(Message message) {
		MapMessage mapMessage = (MapMessage) message;
		try {
			String telephone = mapMessage.getString("telephone");
			String content = mapMessage.getString("content");
			// 发送短信验证码
			String msg = SmsUtils.sendSmsByHTTP(telephone, content);
			if (msg.startsWith("000")) {
				System.out.println("发送成功," + telephone + "," + content);
			} else {
				System.out.println("发送失败");
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
